﻿<DockPanel x:Class="Sunny.Controls.GridPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			xmlns:Telerik="http://schemas.telerik.com/2008/xaml/presentation"
			xmlns:Sunny="clr-namespace:Sunny.Controls"
             mc:Ignorable="d" DataContext="{Binding RelativeSource={RelativeSource Self}}"
 		xmlns:Globalization="clr-namespace:System.Globalization;assembly=mscorlib"
            d:DesignHeight="300" d:DesignWidth="300">
	<DockPanel.Resources>
		<Style TargetType="Sunny:Toolbar">
			<Setter Property="Margin" Value="5" />
			<EventSetter Event="Query" Handler="Toolbar_Query" />
			<EventSetter Event="Reload" Handler="Toolbar_Reload" />
			<EventSetter Event="Export" Handler="Toolbar_Export" />
		</Style>
		<Style TargetType="Telerik:RadGridView">
			<Setter Property="ItemsSource" Value="{Binding ElementName=Pager,Path=PagedSource}" />
			<Setter Property="IsReadOnly" Value="True" />
			<Setter Property="ShowGroupPanel" Value="False" />
			<Setter Property="CanUserResizeRows" Value="False" />
			<Setter Property="AutoGenerateColumns" Value="False" />
			<Setter Property="RowHeight" Value="30" />
			<Setter Property="ItemsSource" Value="{Binding PagedSource, ElementName=Pager}" />
			<EventSetter Event="SizeChanged" Handler="Grid_SizeChanged" />
			<EventSetter Event="Sorting" Handler="Grid_Sorting" />
		</Style>
		<Style TargetType="Telerik:GridViewDataColumn">
			<Setter Property="IsFilterable" Value="False" />
		</Style>
		<Style TargetType="Telerik:GridViewHeaderRow">
			<Setter Property="Height" Value="25"/>
		</Style>
		<Style TargetType="Telerik:GridViewHeaderCell">
			<Setter Property="Padding" Value="10,0,10,0" />
		</Style>
		<Style TargetType="Telerik:GridViewCell">
			<Setter Property="Padding" Value="10,0,10,0" />
		</Style>
		<Telerik:GridViewColumn x:Key="SelectColumn" Name="SelectColumn" IsVisible="False">
			<Telerik:GridViewColumn.Header>
				<WrapPanel DataContext="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Sunny:GridPanel}}}">
					<CheckBox Name="SelectAllCheckBox" IsChecked="{Binding SelectAllChecked}" ToolTip="选择所有记录" Checked="SelectAllCheckBox_Changed" Unchecked="SelectAllCheckBox_Changed" Margin="0,0,5,0" />
					<CheckBox Name="SelectCurrentPageCheckBox" ToolTip="选择本页记录" Checked="SelectCurrentPageCheckBox_Changed" Unchecked="SelectCurrentPageCheckBox_Changed" />
				</WrapPanel>
			</Telerik:GridViewColumn.Header>
			<Telerik:GridViewColumn.CellTemplate>
				<DataTemplate>
					<CheckBox Loaded="CheckBox_Loaded" Unloaded="CheckBox_Unloaded" Checked="CheckBox_Changed" Unchecked="CheckBox_Changed" HorizontalAlignment="Center" />
				</DataTemplate>
			</Telerik:GridViewColumn.CellTemplate>
		</Telerik:GridViewColumn>
	</DockPanel.Resources>
	<ContentControl Content="{Binding Toolbar}" DockPanel.Dock="Top" />
	<!--<Sunny:Toolbar x:Name="Toolbar" Margin="5" Query="Toolbar_Query" />-->
	<Telerik:RadDataPager Name="Pager" DockPanel.Dock="Bottom" PageSize="10" DataContext="{Binding ElementName=Pager}" Margin="0,5,0,0">
		<Telerik:RadDataPager.Template>
			<ControlTemplate>
				<Grid>
					<Grid.Resources>
						<Sunny:Pager_PageIndexConverter x:Key="IndexConverter" />
						<Style TargetType="Image">
							<Setter Property="Stretch" Value="None" />
						</Style>
					</Grid.Resources>
					<WrapPanel HorizontalAlignment="Left">
						<WrapPanel.Resources>
							<Style TargetType="Button">
								<Setter Property="Margin" Value="5,0,0,0" />
							</Style>
						</WrapPanel.Resources>
						<Button ToolTip="第一页" IsEnabled="{Binding CanMoveToFirstPage}" Click="FirstPage_Click">
							<Image Source="Images/First.png" />
						</Button>
						<Button ToolTip="上一页" IsEnabled="{Binding CanMoveToPreviousPage}" Click="PreviousPage_Click">
							<Image Source="Images/Previous.png" />
						</Button>
						<!--CanMoveToNextPage疑似不对-->
						<Button ToolTip="下一页" IsEnabled="{Binding CanMoveToLastPage}" Click="NextPage_Click">
							<Image Source="Images/Next.png" />
						</Button>
						<Button ToolTip="最后一页" IsEnabled="{Binding CanMoveToLastPage}" Click="LastPage_Click">
							<Image Source="Images/Last.png" />
						</Button>
					</WrapPanel>
					<WrapPanel HorizontalAlignment="Center">
						<TextBlock FontSize="12" VerticalAlignment="Center">页码：</TextBlock>
						<Telerik:RadNumericUpDown Name="GoToIndex" NumberDecimalDigits="0" Value="{x:Null}" Margin="5,0,5,0">
							<Telerik:RadNumericUpDown.NumberFormatInfo>
								<Globalization:NumberFormatInfo NumberGroupSeparator="" />
							</Telerik:RadNumericUpDown.NumberFormatInfo>
						</Telerik:RadNumericUpDown>
						<Sunny:Button FontSize="12" Icon="Images/Next.png" Text="转到" Click="GoToPage_Click" />
					</WrapPanel>
					<WrapPanel HorizontalAlignment="Right">
						<WrapPanel.Resources>
							<Style TargetType="TextBlock">
								<Setter Property="FontSize" Value="12" />
							</Style>
						</WrapPanel.Resources>
						<TextBlock>一共</TextBlock>
						<TextBlock Text="{Binding ItemCount}"></TextBlock>
						<TextBlock>条/</TextBlock>
						<TextBlock Text="{Binding PageCount}"></TextBlock>
						<TextBlock>页，当前第</TextBlock>
						<TextBlock Text="{Binding Path=PageIndex,Converter={StaticResource IndexConverter}}"></TextBlock>
						<TextBlock>页</TextBlock>
					</WrapPanel>
				</Grid>
			</ControlTemplate>
		</Telerik:RadDataPager.Template>
	</Telerik:RadDataPager>
	<ContentControl Content="{Binding Grid}" />
</DockPanel>